package com.xbongbong.pro.statistics.configs;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.stereotype.Component;

/**
 * 移出bean。不能移除整个类，因为代码还没有完全隔离出来，统计服务和ck服务共同引用了一些类，移除类会导致依赖了的上层报错
 * @author  梁鲁江 
 * @date 2022年1月11日19:42:13
 */
@Component
public class RemoveRegistyBeanFactoryPostProcessor implements BeanDefinitionRegistryPostProcessor {
    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {
        if (beanDefinitionRegistry.containsBeanDefinition("lowLevelRestClient")){
            beanDefinitionRegistry.removeBeanDefinition("lowLevelRestClient");
            beanDefinitionRegistry.removeBeanDefinition("restHighLevelClient");
        }
 
    }
 
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
 
    }
}
